<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$worker=pdo_get('jy_meifa_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
//exi($_SESSION['uid'],'error');
if($_RQ['op']=='main'){
    $worker=pdo_get('jy_meifa_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if(!$worker){
		exi('找不到员工信息！','error','jy_meifa/store/');
	}
	if($worker['islock']==1){
		exi('您已被锁定，请联系管理员！','error','jy_meifa/store/');
	}
	//今日客户数量
	$day_start = date('Y-m-d', time());
//  $week_start = date('Y-m-d', strtotime('last day this week'));
 // $month_start = date('Y-m-01', time());
    $end = date('Y-m-d H:i:s', time());
	$sql = 'SELECT COUNT(1) FROM '. tablename('jy_meifa_order') . ' WHERE uniacid=:uniacid AND wid=:wid AND status!=3 AND createtime >= UNIX_TIMESTAMP( "'.$day_start.'" ) AND createtime <= UNIX_TIMESTAMP( "'.$end.'" )';
	$today_num = pdo_fetch($sql,array(":uniacid" => $_SESSION['uniacid'],":wid" => $worker['id']));
	
//	$day=date("Y-m-d",time("day"));
//	$today_num2=pdo_count('jy_meifa_order',array('uniacid'=>$_SESSION['uniacid'],'wid'=>$worker['id'],'day'=>$day,'status'=>'2'));
	
	//总订单数量

	$all_num=pdo_count('jy_meifa_order',array('uniacid'=>$_SESSION['uniacid'],'wid'=>$worker['id'],'status !='=>'3'));
	//总业绩
	$sql1 = "SELECT SUM(money) FROM " . tablename('jy_meifa_order') . " WHERE uniacid=:uniacid AND wid=:wid AND status=2";
    $all_money1 = pdo_fetch($sql1,array(":uniacid" => $_SESSION['uniacid'],":wid" => $worker['id']));
	//今日业绩
	$sql4 = 'SELECT SUM(money) FROM ' . tablename('jy_meifa_order') . ' WHERE uniacid=:uniacid AND wid=:wid AND createtime >= UNIX_TIMESTAMP( "'.$day_start.'" ) AND createtime <= UNIX_TIMESTAMP( "'.$end.'" ) AND status=2';
    $today_money = pdo_fetch($sql4,array(":uniacid" => $_SESSION['uniacid'],":wid" => $worker['id']));
	//佣金
	$return['worker']=$worker;
	$return['today_num']=$today_num['COUNT(1)'];
	$return['all_num']=$all_num;
	$return['worker']=$worker;
	$return['all_money']=$all_money1['SUM(pay)'];
	$return['today_money']=$today_money['SUM(pay)'];
	exi($return);
}
//修改员工信息
